<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>后台</title>
    <link href="./css/default.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="./themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="./themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="./kindeditor/themes/default/default.css" />
    <style type="text/css">
		label {
	display: block;
	margin-bottom:6px;
}
	</style>
    <script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="./js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../include/uploadify/swfobject.js"></script>
	<script type="text/javascript" src="../include/uploadify/uploadify.css"></script>
	<script type="text/javascript" src="../include/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
	<?php
		if ($_REQUEST['lang'] == 'sc'){
			echo "<script type='text/javascript' src='./js/locale/easyui-lang-zh_CN.js'></script>";
		}else if ($_REQUEST['lang'] == 'tc'){
			echo "<script type='text/javascript' src='./js/locale/easyui-lang-zh_TW.js'></script>";
		}else{
			echo "<script type='text/javascript' src='./js/locale/easyui-lang-zh_CN.js'></script>";
		}
	?>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#title').validatebox({  
			required:true  
		});
		$('#link').validatebox({  
			required:true  
		});
		$('#img_upload').uploadify({
			'uploader'  : '../include/uploadify/uploadify.swf',
			'expressInstall'  : '../include/uploadify/expressInstall.swf',
			'script'    : '../include/uploadify/uploadify.php',
			'cancelImg' : '../include/uploadify/cancel.png',
			'method'    : 'post',
			'auto'      : true,
			'displayData' : 'percentage',
			'scriptData'  : {'lang':'<?php echo $_REQUEST['lang'];?>'},
			'onComplete'  : function(event, ID, fileObj, response, data) {
				if(response == 'sizeerror'){
					$.messager.alert('错误','请上传340*90或该尺寸整数倍的图片');
				}else if(response == 'success'){
					$('#img').val(fileObj.name);
				}
			}
		});
		$('#save').click(function(){
			<?php
				if ($_REQUEST['lang'] == 'sc'){
					echo "$.messager.confirm('同步确认','是否将当前数据同步到繁体数据段中？（注意：同步会直接覆盖当前繁体版的数据，请谨慎选择）',";
				}else if ($_REQUEST['lang'] == 'tc'){
					echo "$.messager.confirm('同步確認','是否將當前數據同步到繁體數據段中？（註意：同步會直接覆蓋當前繁體版的數據，請謹慎選擇）',";
				}else{
					echo "$.messager.confirm('同步确认','是否将当前数据同步到繁体数据段中？（注意：同步会直接覆盖当前繁体版的数据，请谨慎选择）',";
				}
			?>
			function(r){  
				if (r){
					$.ajax({
						url: "/interface.php",
						async: true,
						type:'POST',
						dataType:'json',
						data:{type:'img',lang:'<?php echo $_REQUEST['lang'];?>',action:'save',id:'<?php echo $_REQUEST['id'];?>',title:$('#title').val(),link:$('#link').val(),img:$('#img').val(),langchange:1},
						success: function(msg){
							if (msg == 'success'){
								$.messager.alert('成功','修改成功！','info',function(){
									var title = window.parent.$('#tabs').tabs('getSelected').panel('options').tab.text();
									window.parent.$('#tabs').tabs('close',title);
								});
							}else{
								<?php
									if ($_REQUEST['lang'] == 'sc'){
										echo "$.messager.alert('失败','修改失败！');";
									}else if ($_REQUEST['lang'] == 'tc'){
										echo "$.messager.alert('失敗','修改失敗！');";
									}else{
										echo "$.messager.alert('失败','修改失败！');";
									}
								?>
							}
						},
						error:function(){
							<?php
								if ($_REQUEST['lang'] == 'sc'){
									echo "$.messager.alert('失败','修改失败！');";
								}else if ($_REQUEST['lang'] == 'tc'){
									echo "$.messager.alert('失敗','修改失敗！');";
								}else{
									echo "$.messager.alert('失败','修改失败！');";
								}
							?>
						}
					});
				}else{
					$.ajax({
						url: "/interface.php",
						async: true,
						type:'POST',
						dataType:'json',
						data:{type:'img',lang:'<?php echo $_REQUEST['lang'];?>',action:'save',id:'<?php echo $_REQUEST['id'];?>',title:$('#title').val(),link:$('#link').val(),img:$('#img').val(),langchange:0},
						success: function(msg){
							if (msg == 'success'){
								$.messager.alert('成功','修改成功！','info',function(){
									var title = window.parent.$('#tabs').tabs('getSelected').panel('options').tab.text();
									window.parent.$('#tabs').tabs('close',title);
								});
							}else{
								<?php
									if ($_REQUEST['lang'] == 'sc'){
										echo "$.messager.alert('失败','修改失败！');";
									}else if ($_REQUEST['lang'] == 'tc'){
										echo "$.messager.alert('失敗','修改失敗！');";
									}else{
										echo "$.messager.alert('失败','修改失败！');";
									}
								?>
							}
						},
						error:function(){
							<?php
								if ($_REQUEST['lang'] == 'sc'){
									echo "$.messager.alert('失败','修改失败！');";
								}else if ($_REQUEST['lang'] == 'tc'){
									echo "$.messager.alert('失敗','修改失敗！');";
								}else{
									echo "$.messager.alert('失败','修改失败！');";
								}
							?>
						}
					});
				}
			});
		});
		$.ajax({
			  url: "/interface.php",
			  async: true,
			  type:'POST',
			  dataType:'json',
			  data:{type:'img',lang:'<?php echo $_REQUEST['lang'];?>',action:'<?php echo $_REQUEST['action'];?>',id:'<?php echo $_REQUEST['id'];?>'},
			  success: function(msg){
				if (msg != 'fail'){
					$('#title').val(msg.title);
					$('#link').val(msg.link);
					$('#img').val(msg.img);
				}
			  }
		});
	});
</script>

</head>
<body>
	<noscript>
		<div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; width:100%; background:white; text-align:center;">
			<img src="images/noscript.gif" alt='抱歉，请开启脚本支持！' />
		</div>
	</noscript>
	<div id="new">
	
		<p style="line-height:1.5em;"><label for="title">标题：</label><input id="title" size="90"></div></p>
		<p style="line-height:1.5em;"><label for="link">链接：</label><input id="link" size="90"></div></p>	
		
		<p style="line-height:1.5em;">
		<label for="editor">图片：</label>
		<input id="img_upload" name="img_upload" type="file" />
		<input id="img" size="90" style="display:none;" />
		</p>
		<input id="save" type="submit" value="提交" />
	</div>
</body>
</html>